<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ page contentType="text/html;charset=UTF-8" language="java" %> 
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <%@ taglib prefix="authz" uri="http://www.springframework.org/security/tags" %>
<%@taglib uri="/struts-tags" prefix="s" %>
<title>bg_sort</title>
<link rel="stylesheet" type="text/css" href="../resource/css/screen.css" />
<script type="text/javascript" src="${pageContext.request.contextPath}/resource/js/jquery-1.4.2.js"></script>
</head>

<body>
    <div class="wrap">
         <div class="header">
              <div class="logo">
                 <a href="#"><img alt="logo" src="../resource/images/brand.gif" /></a>
                 <a href="${pageContext.request.contextPath}/sz/initialPictureType.action" style="top:10px; width:500px;" class="manager_center">图片类型添加</a>
              </div>
              
             
              
         <div class="content">
               <div class="clear"></div>
               <ul id="pictureType">
                  <c:forEach var="pictureType" items="${types}">
	                  <li class="bg_sort">
	                        <a class="sort_img" ><img alt="img" src="../resource/images/bg_sort.gif" /></a>
	                        <p class="sort_name">${pictureType.name}</p>
	                        <p class="del_modify">
                            <authz:authorize ifAnyGranted="ROLE_PIC_MOD,ROLE_ADMIN">
                                <a alt="modify" href="${pageContext.request.contextPath}/sz/modifyPictureType.action?pictureType.typeId=${pictureType.typeId}&pictureType.name=">修改</a> |
	                        </authz:authorize>
                                <authz:authorize ifAnyGranted="ROLE_PIC_DEL,ROLE_ADMIN">
                                <a alt="delete" href="${pageContext.request.contextPath}/sz/delPictureType.action?pictureType.typeId=${pictureType.typeId}">删除</a></p>
	                        </authz:authorize>
                      </li>
                  </c:forEach>
                                 
                   
               </ul>
         </div>
         <div class="pages">
           
         </div>
         
         <div class="footer">
           <span>&copy;</span><span>电子科技大学数字媒体技术研究所</span><span>All rights reserved</span>
           <span>&#124;</span><span>Powered by Dreamfly</span>
         </div>
    </div>
    <script type="text/javascript">
    $(document).ready(function() {
    	$("li.bg_sort").hover(function(){
    		$(this).find("p.del_modify").css("visibility","visible");
    	},function(){
    		$(this).find("p.del_modify").css("visibility","hidden");
    	});
    	$("p.del_modify a").click(function(){
    		var url=this.href;
    		var $li=$(this).parent().parent();
    		if($(this).attr("alt")=="delete"){
    			alert("确定删除？");
    			$.ajax({
    				type:"GET",
    				url:url,
    				dataType:"text",
    				success:function(data){
    					if(data=="success"){
    						$li.remove();
    					}
    				}
    			});
    		}else{
    		 var $p=$(this).parent().parent().find("p.sort_name");
    		 	var sortName=$p.text();
    		 	var htmlStr="<input type='text' value='"+sortName+"' /><br /><a href=''>确定</a>";
    		 	$p.html(htmlStr);
    		 	$p.find("a").click(function(){
    		 	 	url+=$p.find("input").val();
    		 		$.ajax({
    					type:"GET",
    					url:encodeURI(url),
    					dataType:"text",
    					success:function(data){
    						if(data=='success'){
    						$p.html($p.find("input").val());
    						}else{
    							alert("出错请稍后再试");
    						}
    					}
    				});
    				
    				return false;
    		 	});
    		}
    		return false;
    	});
    });
    </script>
</body>
</html>
